package com.fzb.forum4j.po;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
@Entity
public class  Category{

	@OneToMany(mappedBy="category")
	@Fetch(FetchMode.JOIN)
	private Set<Article> articles=new HashSet<Article>(); 
	
	private String categoryName;

	@Id
	@GeneratedValue
	private Integer categroyId;

	@ManyToOne
	@JoinColumn(name="pCategroyId")
	private Category parentCategroy;
	
	@OneToMany(targetEntity = Category.class, cascade = { CascadeType.ALL }, mappedBy = "parentCategroy")  
	@OrderBy("categroyId")
	@Fetch(FetchMode.SUBSELECT)
	private Set<Category> childCategroy=new HashSet<Category>();

	private String catalog;

	public Set<Category> getChildCategroy() {
		return childCategroy;
	}

	public Set<Article> getArticles() {
		return articles;
	}

	public void setArticles(Set<Article> articles) {
		this.articles = articles;
	}

	public String getCategoryName() {
		return categoryName;
	}

	public void setCategoryName(String categoryName) {
		this.categoryName = categoryName;
	}

 

	public Category getParentCategroy() {
		return parentCategroy;
	}
	
	

	public void setParentCategroy(Category parentCategroy) {
		this.parentCategroy = parentCategroy;
	}

	public void setChildCategroy(Set<Category> childCategroy) {
		this.childCategroy = childCategroy;
	}

	public String getCatalog() {
		return catalog;
	}

	public void setCatalog(String catalog) {
		this.catalog = catalog;
	}

	public Integer getCategroyId() {
		return categroyId;
	}

	public void setCategroyId(Integer categroyId) {
		this.categroyId = categroyId;
	}
 

}
